{% extends 'base.html' %}

{% block content %}
    <h2>{{ class_info.grade }} {{ class_info.name }} 班级 {{ date|date:'Y-m-d' }} ({{ date|date:'l' }}) 作业情况</h2>

    {% if subject_without_homework %}
        <div class="alert alert-warning alert-dismissible fade show" role="alert">
            <h4 class="alert-heading">以下科目在指定日期没有作业：</h4>
            {% for subject in subject_without_homework %}
                <span class="me-3">
                    <i class="bi bi-bookmark-x-fill text-warning me-2"></i>{{ subject }}
                </span>
            {% endfor %}
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
    {% endif %}

    {% if homework_stats %}
        {% for subject, info in homework_stats.items %}
            <div class="card mb-3">
                <div class="card-header bg-primary text-white">
                    <h5>{{ subject }} 作业</h5>
                    <span>{{ info.homework.content }}</p>
                </div>
                <ul class="list-group list-group-flush">
                    <li class="list-group-item bg-light fw-bold">
                        <div class="row">
                            <div class="col">学生姓名</div>
                            <div class="col">作业状态</div>
                        </div>
                    </li>
                    {% for student, status_info in info.students.items %}
                        <li class="list-group-item">
                            <div class="row">
                                <div class="col">{{ student }}</div>
                                <div class="col">
                                    {% if status_info.status == 'excellent' %}
                                        <span class="badge bg-success">好</span>
                                    {% elif status_info.status == 'good' %}
                                        <span class="badge bg-info text-dark">中</span>
                                    {% elif status_info.status == 'poor' %}
                                        <span class="badge bg-warning text-dark">差</span>
                                    {% elif status_info.status == 'plagiarism' %}
                                        <span class="badge bg-danger">抄袭</span>
                                    {% elif status_info.status == 'missing' %}
                                        <!-- status 为 'missing' 表示没有提交作业 -->
                                        <span class="badge bg-secondary">未提交</span>
                                    {% endif %}
                                </div>
                            </div>
                        </li>
                    {% endfor %}
                </ul>
            </div>
        {% endfor %}
    {% else %}
        <div class="alert alert-info" role="alert">
            该班级在指定日期没有布置作业。
        </div>
    {% endif %}
{% endblock %}